﻿@model VietPublisher.BaseProject.Models.ViewBook
@*@Model.BookTitle
<br />
@Model.BookCode
<br />
@Model.AuthorName
<br />
@Model.PageNumber
<br />
@Model.PriceCurrent
<br />
@Model.PublisherName
<br />
@Model.Translator
<br />
@Model.Weight
<br />
@Model.Size
<br />
 @Model.Translator

 <img id='imgAppr' alt="picture" name='imgAppr' style="width: 60px; height: 60px" src='<%=string.Format("/Handlers/ImageHandler.ashx?fileId={0}", @Model.pictureID) %>' />
*@
<div class="Clearfix">
    <div class="allvierdettail">
        <div class="DetailImg Clearfix">
            <img id='imgAppr' alt="picture" name='imgAppr' src='@string.Format("/Handlers/ImageHandler.ashx?groupid={0}", @Model.pictureID) ' />
        </div>
        <div class="detailInfo Clearfix">
            <table class="tableDetail" cellpadding="0" cellspacing="0">
                <tr>                   
                    <td colspan="2" style="width: 59%; font-size: 18px; text-align: center; font-weight: bold;
                        height: 30px;">@Model.BookTitle
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span class="titileDetail">Book Code : </span>@Model.BookCode
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span class="titileDetail">Author :</span> @Model.AuthorName
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span class="titileDetail">Publisher :</span> @Model.PublisherName
                    </td>
                </tr>
                </tr>
                <tr>
                    <td colspan="2">
                        <span class="titileDetail">Translator :</span> @Model.Translator
                    </td>
                </tr>
                <tr>
                    <td style="width: 28%; border-top: 1px solid #ccc; padding-top: 10px;">
                        <span class="titileDetail">Price :</span><span class="price"> @Model.PriceCurrent</span>
                    </td>
                    <td style="width: 28%; border-top: 1px solid #ccc; padding-top: 10px;">
                        <span class="titileDetail">Page Number :</span> @Model.PageNumber
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <span class="titileDetail">Weight :</span> @Model.Weight
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <span class="titileDetail">Size :</span> @Model.Size
                    </td>
                </tr>
                <tr>
                    <td style="width: 28%; border-top: 1px solid #ccc; padding-top: 10px;">
                    </td>
                    <td style="width: 28%; border-top: 1px solid #ccc; padding-top: 10px;" align="center">
                        <input type="text" size="2" maxlength="2" value="1" id="quantity" name="quantity" onkeypress="return isNumberKey(event,@Model.BookId); " />
                        <button onclick="fnAddToCart(@Model.BookId);">
                            Add to cart</button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div style="border-top: 1px dashed #CCCCCC; padding: 5px;" class="Clearfix">
    </div>
</div>
<script language="javascript" type="text/javascript">

    function isNumberKey(evt, bookID) {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            return false;
        }

        //        if (evt.keyCode == 13) {
        //            return fnUpdateQuantity(bookID);
        //           }

        return true;
    }

    function fnAddToCart(currentBookId) {
        var currentQuantity = $("#quantity").val();        
     $.ajax({ type: 'GET', url: '/Home/AddToCart', data: { bookID: currentBookId, quantity: currentQuantity }, success: function (response) {
            reloadLogon();
          }
          });    

    }

     

</script>
